'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let roleManagementService = require('../../../service/System/roleManagementService');
let logger = require('../../../util/LoggerUtil').logger('roleManagementController.js');

/**
 * 账户管理页面
 */

module.exports.roleManagementPage = function () {
  let response = new Response();
  response.render('back/system/role-management/role-management');
  this.resolve(response);
};
/**
 * 账户管理列表
 */
module.exports.roleManagementList = async function () {
  let req = this.req;
  let params = req.body;
  let response = new Response();
  try {
    let result = await roleManagementService.roleManagementList(this, params);
    let pageBean = new CustomPageBean(result);
    response.send(pageBean);
  } catch (error) {
    logger.error(error);
  }
  this.resolve(response);
};
/**
 * 账户管理-创建页面
 */
module.exports.roleManagementCreatePage = function () {
  let response = new Response();
  response.render('back/system/role-management/role-management-create');
  this.resolve(response);
};

/**
 * 账户管理-创建页面-保存按钮
 */
module.exports.roleManagementCreateSave = async function () {
  let req = this.req;
  let params = req.body;
  let response = new Response();
  try {
    let result = await roleManagementService.roleManagementCreateSave(this, params);
    response.send(result);
  } catch (error) {
    logger.error(error);
  }
  this.resolve(response);
};
/**
 * 账户管理-修改页面
 */
module.exports.roleManagementUpdatePage = function () {
  let response = new Response();
  response.render('back/system/role-management/role-management-update');
  this.resolve(response);
};
/*分组管理-修改页面-确认按钮*/
module.exports.roleManagementUpdateSave = async function () {
  let req = this.req;
  let params = req.body;
  let response = new Response();
  try {
    let result = await roleManagementService.roleManagementUpdateSave(this, params);
    response.send(result);
  } catch (error) {
    logger.error(error);
  }
  this.resolve(response);
};
/**
 * 分组管理-删除按钮
 */
module.exports.roleManagementDelete = async function () {
  let req = this.req;
  let params = req.body;
  let response = new Response();
  try {
    let result = await roleManagementService.roleManagementDelete(this, params.userId);
    response.send(result);
  } catch (error) {
    logger.error(error);
  }
  this.resolve(response);
};





